<%--
  Created by IntelliJ IDEA.
  User: ASUS
  Date: 2021/12/20
  Time: 21:32
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="utf-8">
    <title>调动信息</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/layui/css/layui.css"  media="all">
    <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>
<body>
<form class="layui-form" action="">
    <div class="demoTable layui-form">
        <div class="layui-form-item">
            <div class="layui-inline" style="float: left">
                <label class="layui-form-label">时间范围</label>
                <div class="layui-input-inline" style="width: 300px">
                    <input type="text" class="layui-input" id="timeFrame" name="timeFrame" placeholder=" - ">
                </div>
            </div>
            <button type="button" class="layui-btn" lay-submit="" lay-filter="search">搜索</button>
        </div>
    </div>
</form>
<table class="layui-hide" id="test" lay-filter="test"></table>
<%--查询所有的出库详情表--%>
<div id="divEle3" style="display: none">
    <table id="demo3" lay-filter="test3" ></table>
    <%--<h1>总计：元</h1>--%>
</div>
<script type="text/html" id="toolbarDemo">
    <div class="layui-btn-container">
        <%-- <button class="layui-btn layui-btn-sm" lay-event="getCheckData">获取选中行数据</button>--%>
        <button class="layui-btn layui-btn-sm" lay-event="isAll">刷新</button>
    </div>
</script>

<%--<script type="text/html" id="barDemo">
    {{#  if(d.state == 1){ }}
    <button type="button" class="layui-btn layui-btn-normal layui-btn-sm" lay-event="adopt">通过</button>
    <button type="button" class="layui-btn layui-btn-danger layui-btn-sm" lay-event="reject">驳回</button>
    {{#  } else { }}
    {{#  } }}
</script>--%>

<script type="text/html" id="information">
    <button type="button" class="layui-btn layui-btn-normal layui-btn-sm" lay-event="detailed">详细信息</button>
</script>

<script type="text/html" id="titleTpl">
    {{#  if(d.state == 1){ }}
    <button class="layui-btn layui-btn-warm layui-btn-sm" style="width: 70px">待审核</button>
    {{# } else if(d.state == 2){ }}
    <button class="layui-btn layui-btn-sm"  style="width: 70px">审核通过</button>
    {{#  } else { }}
    <button class="layui-btn layui-btn-danger layui-btn-sm"style="width: 70px">审核驳回</button>
    {{#  } }}
</script>


<script src="${pageContext.request.contextPath}/layui/layui.js" charset="utf-8"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述 JS 路径需要改成你本地的 -->

<script>
    layui.use(['table','jquery','laydate','form','layer'], function(){
        var table = layui.table;
        var $ = layui.jquery;
        var laydate = layui.laydate;
        var form = layui.form;
        var layer = layui.layer;

        //日期时间范围
        laydate.render({
            elem: '#timeFrame'
            ,type: 'datetime'
            ,range: true
        });

        table.render({
            id: 'test',
            elem: '#test'
            , url: '${pageContext.request.contextPath}/Shopkeeperchange/getAll'
            , toolbar: '#toolbarDemo' //开启头部工具栏，并为其绑定左侧模板
            , title: '员工数据表'
            , cols: [[
                {type: 'checkbox', fixed: 'left'}
                , {field: 'id', title: 'ID', hide: 'true', fixed: 'left', unresize: true, sort: true}
                , {field: 'staffname', title: '员工姓名',templet:function (data){
                        return data.staff==null?"":data.staff.staffname
                    }}
                , {field: 'branchname', title: '原店铺',templet:function (data){
                        return data.branch==null?"":data.branch.branchname
                    }}
                , {field: 'deptname', title: '原部门',templet:function (data){
                        return data.department==null?"":data.department.deptname;
                    }}
                , {field: 'rolename', title: '职位名称',width:160,templet:function (data) {
                        return data.role==null?"":data.role.rolename;
                    }}
                , {field: 'newbranchname', title: '新店铺',templet:function (data){
                        return data.newbranch==null?"":data.newbranch.branchname;
                    }}
                , {field: 'newdeptname', title: '新部门',templet:function (data){
                        return data.newdepartment==null?"":data.newdepartment.deptname;
                    }}
                , {field: 'newrolename', title: '新职位名称',width:160,templet:function (data) {
                        return data.newrole==null?"":data.newrole.rolename;
                    }}
                , {field: 'transfertime', title: '时间'}
            ]],
            page: true,
            limit: 6,
            limits: [3, 6, 9, 12]
        });

        form.on('submit(search)',function(data){
            table.reload('test',{
                where: { //设定异步数据接口的额外参数
                    "timeFrame":data.field.timeFrame,
                    /*bid:$("#branchidSel1").val()*/
                }
                ,page: {
                    curr: 1 //重新从第 1 页开始
                }
            });
        })

        //头工具栏事件
        table.on('toolbar(test)', function(obj){
            var checkStatus = table.checkStatus(obj.config.id);
            switch(obj.event){
                case 'getCheckData':
                    var data = checkStatus.data;
                    layer.alert(JSON.stringify(data));
                    break;
                case 'getCheckLength':
                    var data = checkStatus.data;
                    layer.msg('选中了：'+ data.length + ' 个');
                    break;
                case 'isAll':
                    table.reload('test')
                    break;
                //自定义头工具栏右侧图标 - 提示
                case 'LAYTABLE_TIPS':
                    layer.alert('这是工具栏右侧自定义的一个图标按钮');
                    break;
            };
        });

        //监听行工具事件
        table.on('tool(test)', function(obj){
            var data = obj.data;
            console.log(obj)
            if(obj.event === 'detailed'){
                layer.open({
                    type: 1,
                    content: $("#divEle3"), //这里content是一个普通的String
                    area: ['780px' ,'400px'],
                    offset: 't'
                });

            }
        });
    });
</script>
</body>
</html>
